package com.dayatang.hrm.compensation.infra.hibernate;

import java.util.List;

import org.apache.tapestry5.hibernate.HibernateSessionManager;
import org.hibernate.Criteria;

import com.dayatang.commons.repository.EntityRepositoryHibernateTapestry;
import com.dayatang.hrm.compensation.policy.RoundingModePolicy;
import com.dayatang.hrm.compensation.policy.RoundingModePolicyRepository;

@SuppressWarnings("unchecked")
public class RoundingModePolicyRepositoryImpl extends
		EntityRepositoryHibernateTapestry<RoundingModePolicy, Long> implements
		RoundingModePolicyRepository {

	public RoundingModePolicyRepositoryImpl(
			HibernateSessionManager sessionManager) {
		super(RoundingModePolicy.class, sessionManager);
	}

	@Override
	public <T extends RoundingModePolicy> List<T> findAllPolicy(Class<T> clazz) {
		return getSessionManager().getSession().createCriteria(clazz)
				.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY).list();
	}

}
